package com.zl.tby.core.base.bean;

import lombok.Data;
import org.noear.wood.IPage;

import java.util.List;

/**
 * 列表结果页封装
 * @author changpeng
 * @version 1.0
 * @since 2024/8/6 23:51
 */
@Data
public class TbyPageResult<T> {
    private Integer current;
    private Integer size;
    private Long total;
    private String order;
    private List<T> records;

    public TbyPageResult(IPage<T> iPage, TbyBaseQuery query) {
        this.total = iPage.getTotal();
        this.records = iPage.getList();
        this.size = iPage.getSize();
        this.current = query.getCurrent();
        this.order = query.getOrder();
    }

    public TbyPageResult(IPage<T> iPage, Integer current) {
        this.total = iPage.getTotal();
        this.records = iPage.getList();
        this.size = iPage.getSize();
        this.current = current;
    }

    public TbyPageResult(IPage<T> iPage, Integer current, String order) {
        this.total = iPage.getTotal();
        this.records = iPage.getList();
        this.size = iPage.getSize();
        this.current = current;
        this.order = order;
    }

    public TbyPageResult(List<T> records, Long total, Integer current, Integer size) {
        this.total = total;
        this.records = records;
        this.size = size;
        this.current = current;
    }
}
